<?php
namespace app\store\model;

use think\Db;

class Base
{
    //基本MODEL

    protected $dbPrefix = 'shopdod_'; //表前缀
    protected $dbUser = 'user'; //用户
    protected $dbStoreUser = 'store_user'; //商家
    protected $dbStoreCard = 'store_card'; //消费卡
    protected $dbCostList = 'store_card_cost'; //消费记录
    protected $dbShDevice = 'su_device'; //售货机机器
    protected $dbShdDoor = 'sud_door'; //售货机门
    protected $dbShNotice = 'su_notice'; //售货机通知
    protected $dbShOrder = 'su_order'; //订单日志

    /**
     * 卡类型
     * 1线下充值，2微信充值，3消费
     */
    protected $cardTypes = [
        1 => '线下充值', '微信充值', '消费',
    ];

    //返回格式
    public function toback($code = 0, $msg = '', $data = [], $total = 0)
    {
        return array('code' => $code, 'msg' => $msg, 'data' => $data, 'total' => $total);
    }

    //金额
    public function toNumber($n)
    {
        return round(($n / 100), 2);
    }

    //当前时间
    public function toDate(){
        return date('Y-m-d H:i:s');
    }

    //连接数据库
    public function dbConn($db)
    {
        return Db::name($db);
    }

    public function dbUser(){
        return $this->dbUser;
    }

    public function dbStoreUser(){
        return $this->dbStoreUser;
    }

    public function dbStoreCard(){
        return $this->dbStoreCard;
    }

    public function dbCostList(){
        return $this->dbCostList;
    }
}